﻿using Abp.Application.Navigation;
using Abp.Threading;
using Abp.UI;
using MyCompanyName.AbpZeroTemplate.Web.Areas.Mpa.Models.Layout;
using MyCompanyName.AbpZeroTemplate.Web.Areas.Prm.Startup;
using MyCompanyName.AbpZeroTemplate.Web.Controllers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace MyCompanyName.AbpZeroTemplate.Web.Areas.Prm.Controllers
{
    public class HomeController : AbpZeroTemplateControllerBase
    {
        private readonly IUserNavigationManager _userNavigationManager;

        public HomeController(IUserNavigationManager userNavigationManager)
        {
            _userNavigationManager = userNavigationManager;
        }

        public ActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// ext的主菜单menu
        /// </summary>
        /// <returns></returns>
        public ActionResult GetMainMenu()
        {
            var sidebarModel = new SidebarViewModel
            {
                Menu = AsyncHelper.RunSync(() => _userNavigationManager.GetMenuAsync(PrmNavigationProvider.MenuName, AbpSession.UserId)),
                CurrentPageName = ""
            };
            return Json(sidebarModel.Menu, JsonRequestBehavior.AllowGet);
        }


        //public ActionResult GetTree()
        //{
        //    List<Prm.Controllers.OrganizationTreeDto> res = new List<OrganizationTreeDto>()
        //    {
        //        new  OrganizationTreeDto(){ id="1", parentId="0", text="111", leaf=false,expanded=true,children=
        //            new List<OrganizationTreeDto>()
        //            {
        //                new  OrganizationTreeDto(){ id="2", parentId="1", text="222", leaf=true,children=null} 
        //            }}
        //    };
        //    return Json(res, JsonRequestBehavior.AllowGet);
        //}



    }
}